package com.emp.model;

import java.sql.Date;
import java.util.List;

public class EmpService {
	
	private EmpDAO_interface dao;
	public EmpService(){
		dao = new EmpDAO();
	}
	
	public EmpVO addEmp(String user_name, String user_phone, String user_mail, Date user_birthday){
		
		EmpVO empVO = new EmpVO();
		empVO.setUser_name(user_name);
		empVO.setUser_phone(user_phone);
		empVO.setUser_mail(user_mail);
		empVO.setUser_birthday(user_birthday);
		dao.insert(empVO);
		
		return empVO;
	}
	
	//預留給 Struts 2 用的
	public void addEmp(EmpVO empVO) {
		dao.insert(empVO);
	}
	
	public EmpVO updateEmp(Integer user_id, String user_name, String user_phone, String user_mail, Date user_birthday){
		
		EmpVO empVO = new EmpVO();
		empVO.setUser_id(user_id);
		empVO.setUser_name(user_name);
		empVO.setUser_phone(user_phone);
		empVO.setUser_mail(user_mail);
		empVO.setUser_birthday(user_birthday);
		dao.update(empVO);
		
		return empVO;
	}
		
	//預留給 Struts 2 用的
	public void updateEmp(EmpVO empVO) {
		dao.update(empVO);
	}
	
	public void deleteEmp(Integer user_id){
		dao.delete(user_id);
	}
	
	public EmpVO getOneEmp(Integer user_id){
		return dao.findByPrimaryKey(user_id);
	}
	
	public List<EmpVO> getAll(){
		return dao.getAll();
	}

}
